let rec lmap f xs = match xs with
  [] -> []
| x::xs -> f x :: lmap f xs
;;

let succ n = n+1;;

let rec nats = 0 :: lmap succ nats;;

let rec nth n xs = match (n, xs) with
  (0, (x :: _)) -> x
| (n, (_ :: ys)) -> nth (n-1) ys
| _ -> raise (Failure "nth")
;;


if nth 123 nats = 123 then
  print_string "nth 123 nats = 123, Yes!\n"
else 
  assert false;;

